ZFS WD Red 4k alignment

Hello everyone,

I have a FreeBSD 9.2 machine that I use mostly as a file server/repository for my network. I'd like to upgrade the storage and I was thinking of using three or four WD30EFRX in RAID-Z1, but I'm not sure how to correctly format 4k drives (maybe it's not an issue anymore).

If I simply plug the drives and zpool create tank raidz1 ada0 ada1 ada2 will these three drives be automatically aligned? Or do I have to use gnop and align on every single drive? If the solution is the latter, does this look right?
Code:
gnop create -S 4096 /dev/ada0
gnop create -S 4096 /dev/ada1
gnop create -S 4096 /dev/ada2
zpool create tank raidz1 /dev/ada0.nop /dev/ada1.nop /dev/ada2.nop
zpool export tank
gnop destroy /dev/ada0.nop /dev/ada1.nop /dev/ada2.nop
zpool import tank

Thanks in advance for any input,

Gherardo
 
Last edited by a moderator:
You first align the partition: gpart add -t freebsd-zfs -a 4k -s <size> <geom>. Then you must use gnop() to align ZFS to 4k. Once you have created the zpool that has ashift=12, adding partitions/HDDs to the zpool will always result in ashift=12. This means you can do it either way - create a zpool on one partition then add other partitions or create a zpool with all partitions in one go.

So yes, your code looks right.

EDIT: There are arguments both pro and con for giving ZFS the entire HDD. I'm of the opinion that partition first, then ZFS is healthier but as I stated it's arguable.
 
Last edited by a moderator:
Thanks for the reply. I just completed the procedure and everything went fine :)

On a side note (maybe it's intended) I noticed a weird thing: if you just create a GPT label and then use gnop to set the geometry, the disk reverts to MBR (although it's temporary).
  • gpart create -s gpt ada0 creates a GPT disk as it should.
  • gnop create -S 4096 ada0 the disk is now aligned but gpart show says it's MBR!
  • After you gnop destroy /dev/ada0.nop it reverts back to GPT, but at that point I had already created the RAID-Z1 pool.
So if you export the pool before deleting the *.nop it gives you an error saying that the GPT table is corrupted (and it really is, being MBR).

Anyway, thanks again!
 
Some disks now report their 4K sector sizes using the DIOCGSTRIPESIZE ioctl. See the output of diskinfo -v /dev/adaX to see if yours does:

Code:
# diskinfo -v ada4
ada4
        512             # sectorsize
        2000398934016   # mediasize in bytes (1.8T)
        3907029168      # mediasize in sectors
        4096            # stripesize
        0               # stripeoffset
        3876021         # Cylinders according to firmware.
        16              # Heads according to firmware.
        63              # Sectors according to firmware.
        S2H7J90B308992  # Disk ident.

ZFS automatically creates pools with an ashift value of 12 on such disks.

If you build a pool on whole disks, without any underlying partitions, then it will be 4K sector aligned by default as it starts on sector 0.
 
Back
Top